<script language="javascript">
	function executeFunc( task )
	{ldelim}
		switch( task )
		{ldelim}
			case 'add_projects':
				var parent = '{$parent_id}';
				if (parseInt(parent, 10) > 0) {ldelim}
					window.location = '{$urlControlName}' + '&m=add&parent_id=' + parent;
				{rdelim} else {ldelim}
					window.location = '{$urlControlName}' + '&m=add';
				{rdelim}
				break;

			case 'edit_projects':

				if ( $("input:checked").length > 1) {ldelim}
					alert('Chỉ có thể chỉnh sửa 1 projects');
					return false;

				{rdelim} else if ($("input:checked").length == 1) {ldelim}
					var linkEdit = '{$urlControlName}' + '&m=edit' + '&id=' + $("input:checked").val();
					window.location  = linkEdit;

				{rdelim} else {ldelim}
					alert('Chưa chọn projects chỉnh sửa');
					return false;

				{rdelim}
				break;
		{rdelim}
	{rdelim}

	/**
	 * editCategory
	 */
    function editCategory(id)
    {ldelim}
    	window.location = '{$urlControlName}&m=edit&id=' + id;
    {rdelim}
    /**
     * setParentId
     *
     * This function will set id of a module and then submit form to load child projects
     */
    function setParentId(id)
    {ldelim}
		if (isNaN(id) || id <= 0) {ldelim}
			return false;
		{rdelim}
		$('#parent_id').val(id);
		document.form2.submit();
    {rdelim}
</script>
<div id="leftBox">

<div class="{$clsType}Box" style="display:{$msgBoxDisp}">
  <div class="{$clsType}BoxTop">&nbsp;</div>
  	{foreach from=$messages item=arrMsg}
    	{foreach from=$arrMsg item=msg}
    	<div class="msgBoxContent {$clsIcon}">
      	<p>{$msg}</p>
      	</div>
      {/foreach}
    {/foreach}
</div>

<div class="contentBox">
    <div class="contentBoxTop">
      <h3>Quản lý Projects</h3>
    </div>

    <div class="innerContent">
      <form id="form2" name="form2" method="post" action="">
        <table class="sTable">
          <thead>
            <tr>
              <th width="60"><strong>Thứ tự</strong></th>
              <th align="left"><strong>Tên Projects</strong></th>
              <th align="center"><strong>Xem trang quản trị</strong></th>
              <th><strong>Chức năng</strong></th>
            </tr>
          </thead>

              {foreach from=$projectsList item=project}
              <tr class="oddRow">
                <td class="firstCol"><input type="checkbox" name="cat_id{$project->id}" id="cat_id[{$project->id}]" value="{$project->id}"/></td>
                <td class="secondCol" align="left">
                	<a style="text-decoration:none;">{$project->p_name|escape}</a>
                </td>
                <td><a href="http://localhost/{$project->p_name}/administrator/" target="_blank">Xem trước</a></td>
                <td class="editItem"><ul>
                    <li class="iconEdit"><a href="javascript:void(0)" onclick="editCategory('{$project->id}');">Sửa</a></li>
                  </ul></td>
              </tr>
              {/foreach}

          </table>
        <p>
        	<div align="right">{$paging}</div>
        </p>
        <input type="hidden" name="parent_id" id="parent_id" value="">
      </form>
    </div>
    <!--end of #box-3-->
</div>
</div>

<div id="sidebar" class="rightBoxes">
  <div class="rightBoxesTop">
    <h3>Chức năng</h3>
  </div>
  <div class="rightContent">
    <ul id="sidebarLinks">
	  <li><a href="javascript:void(0);" onclick="javascript:executeFunc('add_projects')">Tạo Projects</a></li>
      <li><a href="javascript:void(0);" onclick="javascript:executeFunc('edit_projects')">Sửa Projects</a></li>
    </ul>
  </div>
</div>
<!-- end of #sidebar -->
